package com.szxx.domain;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.szxx.constans.PokerTableState;

/**
 * 花色
 * 
 * @author Ambrose
 */
public enum CardShape {
	/** 方块 */
	DIAMOND(0, "D"),
	/** 梅花 */
	CLUB(1, "C"),
	/** 红桃 */
	HEART(2, "H"),
	/** 黑桃 */
	SPADE(3, "S"),
	/** 黑鬼 */
	BLACK_JOKER(4, "BJ"),
	/** 红鬼 */
	RED_JOKER(5, "RJ");
	
	private static Logger logger = LoggerFactory.getLogger(PokerTableState.class);
	
	static Map<Integer, CardShape> shapeCache = new HashMap<Integer, CardShape>();
	
	static {
        for (CardShape tState : CardShape.values()) {
            shapeCache.put(tState.getShape(), tState);
        }
    }

    public static CardShape valueOf(int tshape) {
    	CardShape shape = shapeCache.get(tshape);
        if (shape == null && logger.isDebugEnabled()) {
            logger.debug("can not find suitable Shape, tshape:{};", tshape);
        }
        return shape;
    }
    
	private final int shape;
	
	private final String simpleName;
	
	private CardShape(int shape, String simpleName) {
		this.shape = shape;
		this.simpleName = simpleName;
	}

	public int getShape() {
		return shape;
	}
	
	public String getSimpleName() {
		return simpleName;
	}
	
}
